package org.luxor.commons.sms.config;

import org.luxor.commons.sms.client.aliyun.AliyunSmsClient;
import org.luxor.commons.sms.client.qcloud.QcloudSmsClient;
import org.luxor.commons.sms.config.properies.SmsProperties;
import org.luxor.commons.sms.service.ISmsService;
import org.luxor.commons.sms.service.impl.SmsServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * FileStorage 全局配置
 *
 * @author Mr.Yan  @date 2019/11/29
 */
@Configuration
@EnableConfigurationProperties(SmsProperties.class)
public class SmsAutoConfig {

    @Bean
    @ConditionalOnMissingBean
    public QcloudSmsClient qcloudSmsClient(SmsProperties smsProperties) {
        return new QcloudSmsClient(smsProperties.getQcloud());
    }

    @Bean
    @ConditionalOnMissingBean
    public AliyunSmsClient aliyunSmsClient(SmsProperties smsProperties) {
        return new AliyunSmsClient(smsProperties.getAliyun());
    }

    @Bean
    @ConditionalOnMissingBean
    public ISmsService smsService() {
        return new SmsServiceImpl();
    }
}
